package com.msb.servicepassengeruser.controller;


import com.msb.commons.dto.VerificationCodeDTO;
import com.msb.commons.response.ResponseResult;
import com.msb.servicepassengeruser.service.PassengerUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chshh
 * @since 2022-10-24
 */
@RestController
public class PassengerUserController {
    @Autowired
    private PassengerUserService passengerUserService;

    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        return passengerUserService.loginOrRegister(passengerPhone);
    }

    @PostMapping("/userByPhone/{passengerPhone}")
    public ResponseResult getUser(@PathVariable("passengerPhone") String passengerPhone){
        return passengerUserService.getUserByPhone(passengerPhone);
    }
}

